\documentclass[12pt]{article}

\usepackage{hyperref}
\usepackage{verbatim}

\title{\huge{User's Manual}
  \\ \qquad
  \\ \large{For the Log File Parser in MATLAB}}
\date{}
\author{Jie Bao~\footnote{\href{mailto:jie.bao@gmail.com}%
  {\texttt{\underline{jie.bao@gmail.com}}}}}

\renewcommand{\baselinestretch}{1.2}
%\setlength\textheight{8in}
\setlength\textwidth{5in}
%\setlength\parindent{0.25in}
\setlength\parskip{0.05in}

% adjust hyphenation
\hyphenpenalty=5000
\tolerance=1000

\begin{document}

\maketitle

This document describes the usage of a MATLAB tool to parse the XML log files.

\section{Workflow}
\subsection{Prerequisite}
In order to run the MATLAB script mentioned above, one has to include two
MATLAB toolboxes (\texttt{XML I/O Tools} and \texttt{Multiple Precision Toolbox}) 
in the MATLAB search path. To do this, go to \textbf{File} $\rightarrow$ 
\textbf{Set path} $\rightarrow$ \textbf{Add folder}, after selecting both
directories where the toolboxes are located, click \textbf{Save} and then 
\textbf{Close}.

In addition, since the single merged log file from MATLAB is still in XML 
format and thus not compatible with the ArcGIS software, we have to 
convert the \verb=.xml= file to a \verb=.csv= file. To achieve this,
one needs to install the XML template processor 4XSLT, which is
part of the 4Suite toolkit~\footnote{\href{http://4suite.org/index.xhtml}%
{\texttt{\underline{http://4suite.org/index.xhtml}}}}, to convert MATLAB-%
generated XML files to \verb=.csv= files, such that the latter can eventually be
loaded in an arbitrary spreadsheet software (e.g. Microsoft Office Excel, 
OpenOffice.org Writer), saved as an \verb=.xls= file and eventually loaded
in ArcGIS.

\subsection{MATLAB script}
At the MATLAB prompt, first navigate to the directory where both 
\verb=parse_all.m= and \verb=parse_xml.m= are located, then open 
\verb=parse_all.m= and manually define the path of log files and the desired
merged file. Now one can execute \verb=parse_all=, which searches the whole
directory for log files that follow the naming convention (see Sec.~%
\ref{sec:naming_convention}) and concatenates them into a single log file.

\subsection{XML template processor}
In the Windows console, first navigate to the directory where the merged
log file and the XSL stylesheet \verb=my_csv.xsl= are located, then 
execute the command 
\begin{verbatim}
    4xslt -o [CSVFile] [MergedLogFile] my_csv.xsl
\end{verbatim}
where \verb=CSVFile= is the filename of the output \verb=.csv= file and 
\verb=MergedLogFile= is the filename of the merged log file from MATLAB.

\subsection{Spreadsheet software}
Open your favorite spreadsheet software, here we will take Microsoft Office
Excel as an example. Go to \textbf{Data} $\rightarrow$ \textbf{Import External
Data} $\rightarrow$ \textbf{Import Data}, select the previously generated 
\verb=.csv= file. In the \textbf{Text Import Wizard - Step 1 of 3}, choose
\textbf{delimited}; In \textbf{Step 2 of 3}, choose \textbf{Semicolon} as 
delimiter; In \textbf{Step 3 of 3}, first mark all the columns,
then choose \textbf{Text} as column data format, this is to ensure that 
the numerical data will be treated as text and all the decimals will be loaded
into Excel.

\subsection{Filename convention} \label{sec:naming_convention}
In order to run the MATLAB script correctly, all log files should be named 
according to the following convention:
\verb=VP_001_1.xml=.
Here the 3-digit number in the filename represents the log file or subject 
number, and the last digit determines the order, in which log files with the 
same log file number should be loaded.


\section{Code functionality}
The XML parser in MATLAB reads a log file, be it a separated Training/Test
log file or a combined one, the area marker is then set according to the
following rules: 
\begin{itemize}
  \item From the 1st non-gps entry to 'correct belief A' is training (area=1);
  \item From the 1st non-gps entry after 'correct belief A' to 'correct
  belief B' or 'correct belief C' is test (area=2);
  \item For the rest, area=0.
\end{itemize}
The parser also checks if the 'studies map - map removed', 'left route - back
on route' and 'standing - walking' pairs are complete. If not, it generates
an error message. In addition, the parser also sorts all events within a single
log file by their \textbf{Time\_SD}.



\end{document}